package org.spring.springboot.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.spring.springboot.MongoDBDAO.M_BaoLanDao;
import org.spring.springboot.domain.mongoEntity.M_BaoLan;
import org.spring.springboot.service.M_BaoLanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class M_BaoLanServiceImpl implements M_BaoLanService {

  @Autowired private M_BaoLanDao M_BaoLanDao;

  @Override
  @CachePut(value = "M_BaoLan", key = "#M_BaoLan.getId()")
  public M_BaoLan save(M_BaoLan M_BaoLan) {
    return M_BaoLanDao.save(M_BaoLan);
  }

  @Override
  @Cacheable(value = "M_BaoLan", key = "#id")
  public M_BaoLan find(Long id) {
    M_BaoLan m_baoLan = M_BaoLanDao.findById(id).get();
    log.info("去数据库查询了，条件为 id :[{}]", id);
    return m_baoLan;
  }
}
